package com.leyou.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.leyou.item.entity.Sku;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.Map;


public interface SkuMapper extends BaseMapper<Sku> {

    @Update("update tb_sku set stock = stock-#{num},sold = sold+#{num} where id = #{id} and saleable = 1")
    int deductStock(Map<String,Object> sku);
    //int deductStock(@Param("num") Integer num,@Param("id") Long id);
    //mybatis底层会转化为map集合  k1 "num"  v1  num   k2 "id"  v1  id
}